package a8;

public class PrimeGenerator {
	/**
	 * 
	 * @param limit Up to what number
	 */
	public PrimeGenerator(int limit) {
		this.limit = limit;
		current = 2;

	}
	/**
	 * Calculate the next prime in the list
	 */
	public void nextPrime() {
		if( current >= limit)
			return;
		int prime = 2;
		boolean found = false;
		while(!found) {
			found = true;
			for(int i = 2; i <= Math.sqrt(current); i++)
			{
				if(current%i == 0)
				{
					found = false;
					break;
				}
			}
			prime = current;
			current++;
		}
		
		System.out.println(prime);
		return;
	}
	
	private int current;
	private int limit;

}
